package com.io;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author weijingchen
 * @DateTime 2025-06-17
 */
public class FileReaderTest {
    public static void main(String[] args) throws IOException {
        File file = new File("src/main/resources/a.txt");
        test02(file);
    }

    public static void test01(File file) throws IOException {

        FileReader fr = new FileReader(file);
        int read;
        while ((read = fr.read()) != -1) {
            System.out.print((char) read);
        }
        fr.close();
    }

    public static void test02(File file) throws IOException {
        FileReader fr = new FileReader(file);
        char[] chars = new char[1024];
        int read;
        while ((read = fr.read(chars)) != -1) {
            System.out.print(new String(chars, 0, read));
        }
        fr.close();
    }

    public static void test03(File file) throws IOException {

    }

    public static void test04(File file) throws IOException {
    }
}
